package springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import springboot.entity.User;
import springboot.service.UserService;

@RestController

public class IndexController {
	@Value("${myname}")
	private String name ;
	@Autowired
	private UserService userService ;
	@RequestMapping("/index")
	public String index(Integer id) {
		System.out.println("aaa");
		//User user=userService.findById(id);
		return "hello world";
	}
	@RequestMapping("/add")
	public String addUser(String name,Integer age) {
		userService.addUser(name, age);
		
		return "success";
	}
	@ResponseBody
	@RequestMapping("/asyn")
	public String asyn(Integer id) throws Exception {
		System.out.println("controllerǰ");
		userService.delUser(id);
		System.out.println("controller��");
		return name;
	}
	
	@ResponseBody
	@RequestMapping("/username")
	public String username() throws Exception {
		System.out.println(name);
		return name;
	}

}
